/*
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

#ifndef _DIALOGS_H
#define _DIALOGS_H

#include <QDialog>
#include <QString>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QCloseEvent>
#include <QFile>
#include <QString>
#include <QWidget>
#include <QGroupBox>
#include <QPushButton>
#include <QPixmap>
#include <QMessageBox>
#include <QFileDialog>
#include <QFileInfo>

#include "codeText.h"
#include "highlighter.h"
#include "opengl/preview.h"

#define ABOUT_TEXT	"<h1>Lego<span><sup style=\"color: #be6307\">Plot</sup></span></h1>" \
					"<p>GLASSABRASIV s.r.o. <br />" \
					"Sušická 109 <br />" \
					"Radslavice 751 11</p>"

class syntaxError: public QDialog{

	Q_OBJECT

	public:
		enum states{OK, EDIT};
	
	private:
		states state;
		QLabel *label;
		highlighter *high;
		QVBoxLayout *vLayout;
		int line;
	
		void createWarning();
		void createOkButton();
	
	private slots:
		void okClicked();
		void editClicked();
	
	public:
		syntaxError(QWidget *, const QString &, int);
		
		void setFileView(const QString &);
		states getState() const;

};

class algorithmProblem: public QDialog{

	Q_OBJECT
	
	private:
		QLabel *reason;
		QVBoxLayout *vLayout;
		
		void createWarning();
		void createOkButton();
		
	public:
		algorithmProblem(QWidget *, const QString);
		
};

class saveOrNot: public QDialog{

	Q_OBJECT

	public:
		enum saveState{YES, NO, CANCEL};
	
	private:
		QVBoxLayout *vLayout;
		saveState state;
		
		void createText(const QString &);
		void createButtons();
	
	private slots:
		void okClicked();
		void noClicked();
		void cancelClicked();

	public:
		saveOrNot(QWidget *, const QString &);
		
		saveState getState() const;

};

class fileModifiedDialog: public QDialog{

	Q_OBJECT
	
	public:
		enum modifiedState{RELOAD, CLOSE, SAVE};

	private:
		QVBoxLayout *vLayout;
		modifiedState state;
		
		void createText(const QString &);
		void createButtons();
	
	private slots:
		void reloadClicked();
		void closeClicked();
		void saveClicked();
	
	public:
		fileModifiedDialog(QWidget *, const QString &);
		
		modifiedState getState() const;

};

class textEditDialog: public QDialog{

	Q_OBJECT
	
	private:
		QVBoxLayout *vLayout;
		codeEdit *edit;
		
		bool saveAs();
	
	private slots:
		void changed();
	
	protected:
		void closeEvent(QCloseEvent *);
	
	public:
		textEditDialog(QWidget *);
		
		void setFile(const QString &);
		bool isModified() const;
		QString getFile() const;
};

class aboutDialog: public QDialog{

	Q_OBJECT

	private slots:
		void buttonClicked();

	public:
		aboutDialog(QWidget *);

};

class glDialog: public QDialog{

	private:
		preview *glPreview;

	public:
		glDialog(QWidget *, QString &, gObjectContainer *, gObjectContainer *);

};

#endif
